<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Delete File
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.10.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxDeleteDatablock
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.10.2005
    * @copyright essentialmind.com 2005
    ***/
    class ajaxDeleteImage extends ajaxAction{

        public function process(){
            
            $nodeid = (int)$_REQUEST['node'];
            $pageid = (int)$_REQUEST['page'];
            $imageid = (int)$_REQUEST['image'];
            
            if($imageid > 0) {
                $id = $this->db->getOne("SELECT pageid FROM pagemap WHERE id = ".$imageid);
            
                //update database
                $this->db->Execute("UPDATE node_gallery_image SET image = false WHERE id = ".$id);
            } else {
                //now check if there is already a property with that name at that level
                if($pageid > 0){                
                    //get record id
                    $id = $this->db->getOne("SELECT pageid FROM pagemap WHERE id = ".$pageid);
                
                    //update database
                    $this->db->Execute("UPDATE node_shop_article SET image = false WHERE id = ".$id);
                
                    //unlink the files?
                } else {
                    //get record id
                    $id = $this->db->getOne("SELECT objectid FROM objectmap WHERE version = 1 AND nodeid = ".$nodeid);
                
                    //update database
                    $this->db->Execute("UPDATE node_folder_full SET image = false WHERE id = ".$id);
                
                    //unlink the files?
                    //...needs implementation...
                
                }
            }
            $this->r->status = true;
        }
    }
?>